package com.tengju.user.domain.model.sign;

import com.tengju.user.domain.model.user.StarLevelEnum;
import com.tengju.user.domain.model.user.UserIdCode;
import com.tengju.user.domain.shared.DomainException;
import com.tengju.user.domain.shared.DomainExceptionCode;
import java.time.LocalDateTime;
import lombok.Value;
import lombok.experimental.NonFinal;
import org.springframework.util.StringUtils;

@Value
public class StarBlacklist {

    StarBlacklistId starBlacklistId;

    UserIdCode idCode;

    @NonFinal
    String mobile;

    @NonFinal
    StarLevelEnum limitStarLevel;

    StarBlacklistValidStatusEnum validStatus;

    String createBy;

    @NonFinal
    String updateBy;

    LocalDateTime createTime;

    public void edit(Integer limitStarLevel, String operator) {
        if (operator != null) {
            this.limitStarLevel = StarLevelEnum.parseByCode(limitStarLevel);
        }
        if (StringUtils.isEmpty(operator)) {
            throw DomainException.error(DomainExceptionCode.INVALID_DATA, "操作人为空");
        }
        this.updateBy = operator;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
}
